package com.yy.studyspringboot.queue;

import java.util.Objects;
import java.util.concurrent.DelayQueue;


public class QueueTest {

    /**
     * 延迟队列 DelayQueue
     * @param args
     */
    public static void main(String[] args) {
        DelayQueue<Order> queue = new DelayQueue<>();
        queue.put(new Order(1000L*1,"22222"));
        queue.put(new Order(1000L*4,"11111"));
        while (queue.size()!=0){
            Order order = queue.poll();//返回头部，头部没有过期的则返回null
            if (Objects.nonNull(order)){
                System.out.println(order);
            }
        }
    }
}
